< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03090402.xhp

(section: choose) (bookmark: bm_id3143271)
Choose function

Choose 関数

Choose Function [Runtime]
Choose 関数 [実行時](hd_id3143271.1)

Returns a selected value from a list of arguments.
引数のリストの中から、指定された値を返します。(par_id3149234.2)

(/section: choose)

Syntax:
構文:(hd_id3148943.3)

Choose (Index, Selection1[, Selection2, ... [,Selection_n]])
Choose (Index, Selection1[, Selection2, ...[,Selection_n]])(par_id3147560.4)

Parameters:
パラメータ:(hd_id3154346.5)

Index: A numeric expression that specifies the value to return.
Index: 返す値を指定するための数値表式。(par_id3148664.6)

Selection1: Any expression that contains one of the possible choices.
Selection1: 戻り値の候補となる任意の値。(par_id3150791.7)

The Choose function returns a value from the list of expressions based on the index value. If Index = 1, the function returns the first expression in the list, if index i= 2, it returns the second expression, and so on.
Choose 関数は、与えられた値のリストの中から、インデックス値の指定するものを返します。ここでは、インデックス値が 1 であればリスト中の 1 番目の値を返し、インデックス値が 2 であればリスト中の 2 番目の値を返す、という処理が行われます。(par_id3151043.8)

If the index value is less than 1 or greater than the number of expressions listed, the function returns a Null value.
インデックス値が 1 より小さいか、リストの要素数よりも大きい場合、関数の戻り値は Null 値が返されます。(par_id3153192.9)

The following example uses the Choose function to select a string from several strings that form a menu:
下記の例では、Choose 関数を使って、メニューを構成する複数の文字列の中から、特定の文字列を取り出しています。(par_id3156281.10)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

Example:
例:(hd_id3150439.11)

Sub ExampleChoose
Sub ExampleChoose(par_id3153091.12)

Dim sReturn As String
Dim sReturn As String(par_id3152597.13)

sReturn = ChooseMenu(2)
sReturn = ChooseMenu(2)(par_id3155855.14)

Print sReturn
Print sReturn(par_id3148575.15)

end sub
end sub(par_id3154012.16)

Function ChooseMenu(Index As Integer)
Function ChooseMenu(Index As Integer)(par_id3146921.19)

ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format")
ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format")(par_id3156443.20)

End Function
End Function(par_id3148645.21)


< Prev / Next >